// pages/me/me.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    userinfo:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var _this=this
    wx.getSetting({
      success(res) {
        if (!res.authSetting['scope.userinfo']) {
          wx.authorize({
            scope: 'scope.userinfo',
            success() {
              console.log('已同意')
              // 用户已经同意小程序使用录音功能，后续调用 wx.startRecord 接口不会弹窗询问
              _this.getUserInfo()
            }
          })
        }
      }
    })
  },
  worksheet:function(e){
    wx.navigateTo({
      url: '/pages/worksheet/worksheet',
    })
  },
  getUserInfo:function(){
    wx.getUserInfo({
      success(res) {
        console.log(res)
        const userInfo = res.userInfo
        const nickName = userInfo.nickName
        const avatarUrl = userInfo.avatarUrl
        const gender = userInfo.gender // 性别 0：未知、1：男、2：女
        const province = userInfo.province
        const city = userInfo.city
        const country = userInfo.country
      }
    })
  }
})